package cn.edu.abc.wangzi.ui;
/*
 *  项目名：Wangzi
 *  包名：cn.edu.abc.wangzi.ui
 *  创建者：SKFsky
 *  创建时间：2017/8/30 0:16
 *  描述:   设置界面
 */

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.Toast;
import cn.edu.abc.wangzi.R;
import cn.edu.abc.wangzi.utils.ShareUtils;

public class SettingActivity extends BaseActivity implements View.OnClickListener{

    private LinearLayout ll_update,ll_scan,ll_qr_code,ll_my_location,ll_about;
    private Switch sw_speak;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        initView();
    }

    private void initView() {
        sw_speak = (Switch) findViewById(R.id.sw_speak);
        sw_speak.setOnClickListener(this);
        boolean isSpeak = ShareUtils.getBoolean(this, "isSpeak", false);
        sw_speak.setChecked(isSpeak);

        ll_update = (LinearLayout) findViewById(R.id.ll_update);
        ll_update.setOnClickListener(this);
        ll_scan = (LinearLayout) findViewById(R.id.ll_scan);
        ll_scan.setOnClickListener(this);
        ll_qr_code = (LinearLayout) findViewById(R.id.ll_qr_code);
        ll_qr_code.setOnClickListener(this);
        ll_my_location = (LinearLayout) findViewById(R.id.ll_my_location);
        ll_my_location.setOnClickListener(this);
        ll_about = (LinearLayout) findViewById(R.id.ll_about);
        ll_about.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.ll_update:
                new AlertDialog.Builder(this)
                        .setTitle("版本检查")
                        //content
                        .setMessage("当前已经是最新版本！")
                        .setNegativeButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //我什么都不做，也会执行dismis方法
                    }
                }).show();
                break;
            case R.id.ll_scan:
                Toast.makeText(this,"此功能尚未开放！",Toast.LENGTH_SHORT).show();
                break;
            case R.id.ll_qr_code:
                Toast.makeText(this,"此功能尚未开放！",Toast.LENGTH_SHORT).show();
                break;
            case R.id.ll_my_location:
                Toast.makeText(this,"此功能尚未开放！",Toast.LENGTH_SHORT).show();
                break;
            case R.id.ll_about:
                startActivity(new Intent(this,AboutActivity.class));
                break;
            case R.id.sw_speak:
                sw_speak.setSelected(!sw_speak.isSelected());
                ShareUtils.putBoolean(this,"isSpeak",sw_speak.isChecked());
                break;
        }
    }
}
